function loadSearchPage(page) {
	
	console.log("Book Search page");

	/* The following line loads the BookSearch.jsp from the server */
//	$('#pageContentAreaDiv').load(page);
	
	/* the following approach is working fine */
	var	response= null;
	response = sendPostRequest(page, "POST", null);
	$("#pageContentAreaDiv").html(response);
	
}


function sendPostRequest(urlStr, httpMethod, payload) {
	var response = null;
	$.ajax( {url:urlStr, 
						async:false,
						cache:false,
						type:httpMethod,
						data: payload,
						success:function(result) {
							response =result;
						}
	 				});

	return response;
}

function searchArtical(articalTypeVal, page){
	searchTextVal = $("#searchText").val();

	/* construct payload */
	payload={articalType: articalTypeVal, searchText: searchTextVal};
	
	/* send request */
	sendSearchRequest(page, "POST", payload);
}

function searchBooksInSolr() {
	url = "http://127.0.0.1:8983/solr/TIC-SearchEngine/select";
	searchTextVal = $("#searchText").val();
	/* encode the search Text */
	searchTextVal=encodeURI(searchTextVal);
	
	query="q=pageText:"+searchTextVal;

//	sendSearchRequest(url, "GET",query);
	
	
	$.ajax({
		  type: "GET",
		  dataType: "xml",
		  url: url,
		  data: query,
		  success: function(xml){
			  alert("response success:"+xml);
		  	},
		  
		  	error:function() {
			  alert("failed");
		  }
		  });
	
}


function sendSearchRequest(urlStr, httpMethod, payload) {

	$.ajax( {url:urlStr, 
					async:false,
					cache:false,
					type:httpMethod,
					data: payload,
					success:function(result) {
						renderSearchResults(result);
					},
					error:function(jqXHR, statusCode, errotThrown){
						searchRequestErrorHandler(jqXHR, errotThrown);
					}
	 			});
	
}

function renderSearchResults(searchResults) {
	alert("renderSearchResults method. response:"+searchResults);
}

function searchRequestErrorHandler(jqXHR, errotThrown){
	alert("searchResults Error Handler, Status code:"+jqXHR.status+" Response:"+jqXHR.responseText);
}